the main reference to the http://blog.csdn.net/anonymalias/article/details/9197641 (anonymalias column)
A record lock is an extended type of read-write lock in thread synchronization and can be used to synchronize file reading and writing with a
Refer to the differences between FCNTL (), LOCKF, flock in LinuxWhat is the difference between these three functions , which are all about locking up a file?First flock and fcntl are system calls, and LOCKF is a library function . LOCKF is actually
In linux low-level file programming, file locks are an important part of multi-user multi-task operating systems. When updating a file, you expect to use a mechanism to prevent both processes from simultaneously updating the file in the same region,
Fcntl (file lock)Header file # include # Include Function Definition int fcntl (int fd, int cmd, struct flock * Lock );Function Description FD: file descriptorThe configured file descriptor. The cmd parameter indicates the command to
Transferred from: http://www.cnblogs.com/Jezze/archive/2011/12/23/2299861.htmlSimple generalization: FD is just an integer that is generated when open. As an index, the process uses the file descriptor in the PCB to find the file pointer Filp that
In the process of simultaneous operation of the same file by multiple processes, it is very easy to cause data confusion in the file, need to lock operation to ensure the integrity of the data, the file-based lock described here, called "File
The function of a record lock is that when a process is reading or modifying a part of a file, it can prevent other processes from modifying the same file area. Record locks are actuallyA byte range lock, because it locks only one area of the file,
Shing
Email: [Email protected]
Blog: Http://blog.csdn.net/qifengzou
Date: 2014.09.12
Reprint please indicate the CSDN blog from "Chifeng"
1 OverviewA system that contains multiple threads/processes will often have multiple
The general lsof will output the following information:COMMAND: Name of the processPID: Process IdentifierPPID: Parent Process Identifier (the-R parameter needs to be specified)USER: Process OwnerPgid: The group to which the process belongsFD: File
Often in the shell script to block other processes, such as MSMTP mail queue script, this script mutex is not correct, the following is the three found in the file to achieve mutual exclusion of the correct approach.
1. The Flock of Util-linux
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.